<template>
  <div class="reset">
    <group>
      <x-input placeholder="请输入密码" v-model="pwd" type="password">
        <span slot="label">密&emsp;&emsp;&emsp;&emsp;码：</span>
      </x-input>
      <x-input placeholder="请重新输入密码" v-model="repwd" type="password">
        <span slot="label">重新输入密码：</span>
      </x-input>
    </group>
    <agent-button @btnClick="nextClick" class="next" :disabled="!pwd.length > 0 || !repwd.length > 0">下一步</agent-button>
  </div>
</template>

<script>
import { Group, XInput } from "vux";
import AgentButton from "../../components/common/AgentButton.vue";
export default {
  data() {
    return {
      pwd: "",
      repwd: ""
    };
  },
  components: {
    Group,
    XInput,
    AgentButton
  },
  methods: {
    nextClick() {
      if (this.pwd !== this.repwd) {
        return this.$vux.toast.text("两次输入的密码不一致");
      }
      this.apiService.user
        .resetpwd({
          newpassword: this.pwd,
          confirmpassword: this.repwd
        })
        .then(res => {
          this.$router.go(-3);
        });
    }
  }
};
</script>

<style scoped>
.reset {
  text-align: center;
}
.next {
  margin: 0.5rem auto;
  width: 90%;
}
</style>

